package com.ruoyi.system.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.TMedicalOrderMapper;
import com.ruoyi.system.domain.TMedicalOrder;
import com.ruoyi.system.service.ITMedicalOrderService;
import com.ruoyi.common.core.text.Convert;

/**
 * 医嘱信息Service业务层处理
 * 
 * @author 杨一迪
 * @date 2024-12-29
 */
@Service
public class TMedicalOrderServiceImpl extends ServiceImpl<TMedicalOrderMapper,TMedicalOrder> implements ITMedicalOrderService

{
    @Autowired
    private TMedicalOrderMapper tMedicalOrderMapper;

    /**
     * 查询医嘱信息
     * 
     * @param id 医嘱信息主键
     * @return 医嘱信息
     */
    @Override
    public TMedicalOrder selectTMedicalOrderById(Long id)
    {
        return tMedicalOrderMapper.selectTMedicalOrderById(id);
    }

    /**
     * 查询医嘱信息列表
     * 
     * @param tMedicalOrder 医嘱信息
     * @return 医嘱信息
     */
    @Override
    public List<TMedicalOrder> selectTMedicalOrderList(TMedicalOrder tMedicalOrder)
    {
        return tMedicalOrderMapper.selectTMedicalOrderList(tMedicalOrder);
    }

    /**
     * 新增医嘱信息
     * 
     * @param tMedicalOrder 医嘱信息
     * @return 结果
     */
    @Override
    public int insertTMedicalOrder(TMedicalOrder tMedicalOrder)
    {
        tMedicalOrder.setCreateTime(DateUtils.getNowDate());
        return tMedicalOrderMapper.insertTMedicalOrder(tMedicalOrder);
    }

    /**
     * 修改医嘱信息
     * 
     * @param tMedicalOrder 医嘱信息
     * @return 结果
     */
    @Override
    public int updateTMedicalOrder(TMedicalOrder tMedicalOrder)
    {
        tMedicalOrder.setUpdateTime(DateUtils.getNowDate());
        return tMedicalOrderMapper.updateTMedicalOrder(tMedicalOrder);
    }

    /**
     * 批量删除医嘱信息
     * 
     * @param ids 需要删除的医嘱信息主键
     * @return 结果
     */
    @Override
    public int deleteTMedicalOrderByIds(String ids)
    {
        return tMedicalOrderMapper.deleteTMedicalOrderByIds(Convert.toStrArray(ids));
    }

    /**
     * 批量软删除医嘱信息
     *
     * @param ids 需要软删除的医嘱信息主键
     * @return 结果
     */
    @Override
    public int softDeleteTMedicalOrderByIds(String ids)
    {
        String[] strArray = Convert.toStrArray(ids);
        int count = 0;
        for (String s : strArray) {
            TMedicalOrder tMedicalOrder = tMedicalOrderMapper.selectTMedicalOrderById(Long.valueOf(s));
            tMedicalOrder.setIsDelete(1);
            int i = tMedicalOrderMapper.updateTMedicalOrder(tMedicalOrder);
            count = count + i;
        }
        return count;
    }

    /**
     * 删除医嘱信息信息
     * 
     * @param id 医嘱信息主键
     * @return 结果
     */
    @Override
    public int deleteTMedicalOrderById(Long id)
    {
        return tMedicalOrderMapper.deleteTMedicalOrderById(id);
    }
}
